<?php
    class enrollModel extends Model{
		//插入用户信息
	    public function insert(){
		   $username=$_POST['username'];
		   $email=$_POST['email'];
		   $telephone=$_POST['telephone'];
		   $password=$_POST['password'];
		   $date=date('Y-m-d H:i:s');
		   session_start();
		   $_SESSION['user']=$username;
           $sql="INSERT INTO `user`(`id`, `head_portrait`, `username`, `nickname`, `sex`, `address`, `email`, `telephone`, `password`, `date`) VALUES (null,null,'{$username}',null,null,null,'{$email}','{$telephone}',md5('{$password}'),'$date')";
           return $rs = $this->db->query($sql);
		}	 
		//获取姓名比对数据
	    public function username_check(){
            $username = $_POST['username'];
            $sql = "SELECT * FROM user WHERE username='{$username}'";
            return $rs = $this->db->fetchRow($sql);
        }
		//获邮箱名比对数据
		public function mail_check(){
            $email=$_POST['email'];
            $sql = "SELECT * FROM user WHERE email='{$email}'";
            return $rs = $this->db->fetchRow($sql);
        }
	    //获取电话号码比对数据
		public function telephone_check(){
            $telephone = $_POST['telephone'];
            $sql = "SELECT * FROM user WHERE telephone='{$telephone}'";
            return $rs = $this->db->fetchRow($sql);
       }                 
	}
?>